import { ListService } from '@abp/ng.core';
import { Component } from '@angular/core';
import { ThemeService } from '../../services';
import { GetIdentityUsersInput, IdentityUserDto } from '../proxy/identity';
import { ListBottonsConfigService } from '../../services/list-buttons-config.service';
import { EntityListComponent } from '../../core/entity-list.component';
import { IdentityUserListService } from './user-list.service';
import { RefPermissionService } from '../ref-permission/ref-permission.service';

@Component({
  selector: 'app-user-list',
  templateUrl: './user-list.component.html',
  providers: [ListService, ListBottonsConfigService],
})
export class UserListComponent extends EntityListComponent<IdentityUserDto> {
  constructor(
    public readonly list: ListService<GetIdentityUsersInput>,
    public buttonConfigService: ListBottonsConfigService,
    public identityUserListService: IdentityUserListService,
    public theme: ThemeService,
    public refPermissionService: RefPermissionService
  ) {
    super(list, buttonConfigService, identityUserListService);
  }

  public editPermission(model: IdentityUserDto, event?: Event) {
    event?.stopPropagation();
    this.refPermissionService.show({ providerName: 'U', keyModel: model }).subscribe();
  }
}
